package com.alibaba.otter.canal.walnut;

import org.apache.commons.lang.exception.ExceptionUtils;

public class WalnutClient extends WalnutClientAbstract{

    public WalnutClient(String destination){
        super(destination);
    }

    public WalnutClient(){
        this(null);
    }

    public static void main(String args[]) {
        // 根据ip，直接创建链接，无HA的功能
        final WalnutClient client = new WalnutClient();
        client.start();
        Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
                try {
                    logger.info("## stop the canal client");
                    client.stop();
                } catch (Throwable e) {
                    logger.warn("## something goes wrong when stopping canal:\n{}", ExceptionUtils.getFullStackTrace(e));
                } finally {
                    logger.info("## canal client is down.");
                }
            }
        });
    }
}
